Skip to content

feat(core): requires knowledge mounts the knowledge service and one vector store - #37442

Draft
objectstack-fleet[bot] wants to merge 11 commits into
mainfrom
claude/project-thread-pvvkab
Draft

objectstack-fleet[bot] wants to merge 11 commits into
mainfrom
claude/project-thread-pvvkab

Conversation

@objectstack-fleet

@objectstack-fleet objectstack-fleet Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Requested by Warren · project thread

Fixes #37102

Clause-②: yes
Metadata-protocol: added
Skills-docs: follow-up #37310

维护者速读

  • 用户能看到什么变化:应用声明需要“知识检索”后,平台自动装好检索服务和一个向量库(PostgreSQL 项目用同一个数据库,其他数据库用项目本地的一个文件);没有声明的部署前后完全一样。
  • 为什么做:属于“知识检索平台化”专题,让本地开发和自建部署不用手工接线就有可用的检索。
  • 出错会怎样:只影响声明了该能力的应用;检索源指向没装上的向量库时应用照常启动,检索会明确报错并说明可选的库;回退本改动即可恢复原状。
  • 要你做什么:批准一次。本改动在两份对外技能文件里各补了一个能力名(受管的技能文件),需要你批准后才能合并。

What changes

  • New capability token knowledge in PLATFORM_CAPABILITY_TOKENS / PLATFORM_CAPABILITY_PROVIDERS (provider @objectstack/service-knowledge, edition open) and in core CAPABILITY_PROVIDERS.
  • Store selection, shared by both boots (@objectstack/core): resolveKnowledgeStore / resolveCapabilityExtras + KNOWLEDGE_STORE_PROVIDERS. PostgreSQL (driver postgres or a postgres(ql):// URL) → KnowledgePgvectorPlugin on the same URL; :memory: → in-memory turso; anything else → KnowledgeTursoPlugin on knowledge.db in the data directory (.objectstack/data/, or <OS_HOME>/data/ when OS_HOME is set) with urlFromSettings. knowledge-memory is never mounted.
  • os serve reads the primary database it resolved and mounts the one store; an extra that cannot be imported or constructed now warns instead of being skipped silently. A host that mounts the service or a store itself keeps its own (hasPluginMatching on the identities).
  • @objectstack/verify constructServedProviders takes an optional database (default in-memory SQLite) and mounts the same store as serve.
  • Unmounted adapter (service-knowledge): service mounts, boot does not fail; at kernel:bootstrapped one error line per such source naming the mounted adapters; index and search of that source answer SERVICE_UNAVAILABLE 503 with the same message (existing code, no new error code). A multi-source search keeps the other sources' hits and names the refused one.
  • Carry from knowledge-turso moves into objectstack: Apache-2.0, the platform embedder and splitter, listing, generations, the contract suite #37107 (comment 7181713320) (knowledge-turso): under the token the store URL comes from settings (knowledge.turso_url / turso_auth_token). resolveSettingsStoreUrl holds a saved file: URL to the realpath'd .objectstack/data/ (symlink escape, .., the directory itself and the platform DB file are refused) and refuses a NUL or other control character, all before createClient. resolveStoreUrl refuses control characters too.
  • The saved store URL is read at kernel:bootstrapped, not in start() (knowledge-turso, fix round). The settings service answers a saved value only once its data engine is bound, in its own kernel:ready hook; a read in start() saw the manifest default while the saved row sat unread, so the store opened the default file whatever the operator had saved (check:settings-bind-window named it; reproduced on a real kernel, see Verification). Under urlFromSettings the adapter is now registered in start() with no database and answers SERVICE_UNAVAILABLE 503; the plugin registers its kernel:bootstrapped handler in init(), so it runs ahead of every handler a plugin registers in start(): the knowledge service's embedder, its reading of unmounted adapters, and the first build of service-knowledge: a source that was never built gets built, and an operator can start a rebuild #37099 find the store open. A store given url or client opens in start() as before. The plugin's optionalDependencies keep only the knowledge service: no ordering edge moves a start() read past the settings bind.
  • Rework after contract record 7187791236 (FAIL on M1) and the seat's REWORK note:
    • M1, a percent-encoded control character is refused (knowledge-turso). resolveStoreUrl and resolveSettingsStoreUrl tested the raw URL only, so a saved file:…/k%00.db passed both; libSQL decodes the path it opens and its native library ends the process on the NUL byte, at every boot. Both now read each %XX escape as the character it encodes and refuse a control character in either spelling, before anything touches the disk or the client. The check is in resolveStoreUrl, so the plugin's own url option holds too.
    • S3, @objectstack/knowledge-turso is an optional dependency of @objectstack/cli and @objectstack/verify (it was a hard one in the first round). Its libSQL client is a native module with an os / cpu list; as a hard dependency it would refuse the whole CLI install outside that list. KNOWLEDGE_STORE_PROVIDERS.turso and its CapabilityExtra carry optional: true. os serve already warns when an extra cannot be imported and boots on; constructServedProviders now does the same for an optional extra (any other provider it cannot load is still a thrown boot error).
    • S4, the store's file follows OS_HOME (os start --home sets it): resolveKnowledgeStore hands the store stateDir, and the data directory is then <OS_HOME>/data/, the directory the boot keeps the default platform database in (resolveDatabaseStateDir's order). The settings confinement moves with it, so an operator can keep the file on the volume. Without OS_HOME nothing changes. New plugin option stateDir; dataDirectoryOf and defaultStoreUrl take it as a second argument. A database named by URL does not move the store (documented).
    • Docs (knowledge-rag.mdx): where the file is, what more than one replica means on MySQL, MongoDB or remote libSQL (one local file per replica, each indexing only its own writes: use a shared libsql:// store or PostgreSQL), and an install without the libSQL client.
    • Changeset: the sentence about a host-mounted service no longer overstates (a host that mounts the service gets no store from the runtime).
  • After the delta record 7193770862 (PASS) and the seat's note 7193780591: the auth token is checked too (knowledge-turso, commit 664bd70). turso_auth_token is the second settings value handed to the libSQL client. A token with a NUL byte, a line break or another control character is refused in the plugin's one open path (open()), for the saved setting and for the authToken option alike, before the client is created; the store answers SERVICE_UNAVAILABLE with a reason that never quotes the token. It is read as written, with no percent-decoded reading: the client percent-decodes a URL (an authToken in a URL's query is already covered by M1's check), never this option, so %00 in a token is three characters. Probed on the installed @libsql/client 0.18.0 before the change, to know what the check prevents: on a file: URL a NUL or a line break in the token opens and answers a query (exit 0, no abort: the native open ignores the token without a sync URL); on http:// every request is rejected with a catchable TypeError (invalid header value); on ws:// the connection was refused before the token was used, so that arm is unmeasured. So no process abort was found; the check turns a failure at every call into one refusal that names the setting. N4: the knowledge.manifest.ts jsdoc now names the state directory's data directory and both spellings of a control character.
  • Settings manifest + 11 locales: the turso_url example path is now file:./.objectstack/data/knowledge.db.
  • Docs: content/docs/ai/knowledge-rag.mdx gains "Turning it on: requires: ['knowledge']"; the old "Wiring" section is now "Wiring by hand".
  • Skills enumeration rows only (Tier H), under the enumeration-row case (ruling A on Adding a top-level key or a bound enum member reds two-way skill gates in both card orders under the skills split #32584): the token's one CAPABILITY_ROWS line in packages/spec/scripts/lib/platform-catalog.ts and its regenerated page skills/objectstack-project/references/platform-catalog.md (gen:skill-refs, no hand edit), and the bare knowledge token added to the @objectstack/service- + token cell of the requires: table in skills/objectstack-platform/SKILL.md. No teaching, examples or evals: those ride skills/objectstack-ai and the MCP authoring contract teach knowledge_source as metadata: name, an explicit content list, no wildcard, the retired keys, and a create seed #37310.
  • Two ceilings, each raised by its row's measured delta and by no more (nothing else cut, nothing rides along):
  • The two rulings the raise path names, quoted:
  • Skills readings on this head against main 5dbcc02 (lines; tokens as the ratchet prices them): skills/objectstack-platform/SKILL.md 422 to 422 lines, 6149 to 6152 tokens; skills/objectstack-project/references/platform-catalog.md (generated) 160 to 161 lines, 2878 to 2898 tokens; all SKILL.md files together 4961 to 4961 lines; the whole shipped bundle reads 299343 tokens, of which this PR adds 23 (3 + 20).
  • packages/cli/src/utils/boot-preparation-parity.test.ts: resolveCapabilityExtras is a SERVE_ONLY entry (the declaration boot reads a row's extras itself and composes no knowledge store: a store's init() declares nothing, its tables are its own). Editing the file put it in check:test-source-alias's changed-file scope, so it now pays six dynamic imports its step modules reach at collection (six module-top side-effect imports, the gate's printed remedy).

Tests

  • packages/verify/src/harness.required-providers.test.ts: requires: ['realtime','knowledge'] on SQLite boots the service + turso (not pgvector), a record write is indexed and search finds it, a pgvector source is refused 503 while boot succeeds; no token → no service and settings.getNamespace('knowledge') rejects SETTINGS_UNKNOWN_NAMESPACE; host-mounted service unchanged.
  • packages/plugins/knowledge-pgvector/src/__tests__/capability-mount.live-postgres.test.ts (new, live cell): the token's resolution on PostgreSQL picks pgvector on the same URL; a record write is indexed and search_knowledge finds it. It has not run in CI on any commit of this PR: the job with a PostgreSQL service, temporal-conformance, does not run on pull_request, and Test Core collects the file with both cases skipped. Its first CI run is the merge queue (the PR touches packages/plugins/knowledge-pgvector/**, which is in the temporal_live filter). It did run locally in the rework round, against PostgreSQL 16.15 with pgvector 0.6.0 from the distribution's package (CI pins pgvector 0.8.7): see Verification.
  • packages/core/src/capability-composition.test.ts: store selection arms (pg driver/URL, other DBs, in-memory, env fallback) and extras.
  • packages/plugins/knowledge-turso/src/__tests__/plugin.test.ts: resolveSettingsStoreUrl (NUL/control, inside, outside, symlink escape, platform file) and the plugin never reaching a mocked createClient with a refused URL. Fix round: the settings double now answers a saved value only once bound, as the real service does, and the cases run a boot in kernel order (init(), start(), the bind, kernel:bootstrapped). New case: nothing is read and no file is made in init() or start(), the mounted adapter answers SERVICE_UNAVAILABLE / 503 until the boot completes, then the saved file opens and the default file is never made.
  • Rework round, plugin.test.ts: %00, %0a, %0A, %7f, a file:// form and a libsql:// URL are refused by both resolvers, with a control (%20 and a doubly encoded %2500 are names, not control characters); a saved %00 or %0a URL never reaches a mocked createClient; a state directory moves the default file and the confinement.
  • Rework round, harness.required-providers.test.ts: a real-kernel case for the file-database arm (constructServedProviders with a file: database under a temporary OS_HOME, a turso_url saved from a kernel:ready handler: the store is healthy on the saved file, neither default file is made, a record write is found by search); an install without the store (the package made unimportable: the service is constructed, the store is not, one warning); the dependency pin now requires an optional store to be an optional dependency and nothing else.
  • Rework round, capability-composition.test.ts: OS_HOME is handed to the file arm as stateDir, and to no other arm.
  • Token round, plugin.test.ts: a token with a NUL byte, a trailing line break, a CR LF or U+007F never reaches a mocked createClient, through the settings door (on a libsql:// URL and on a file inside the data directory) and through the authToken option; no log line quotes the token; controls: a JWT-shaped token and one with %00 in it reach the client as written.
  • packages/services/service-knowledge/src/__tests__/knowledge-service.test.ts: boot reading, coded index/search refusals, the plugin hook.
  • packages/cli/test/serve-capability-identity.test.ts: identity rows for the service and both stores.

Acceptance notes

Verification

First files to read, by risk:

  1. packages/plugins/knowledge-turso/src/plugin.ts: init() / start() / openFromSettings (when the store opens, and what it answers before).
  2. packages/core/src/capability-composition.ts: resolveKnowledgeStore (which store, with what argument).
  3. packages/services/service-knowledge/src/knowledge-service.ts: getAdapter / reportUnmountedAdapters (the coded refusal).

Two-minute check: pnpm --filter @objectstack/knowledge-turso exec vitest run --maxWorkers=2 src/__tests__/plugin.test.ts: expect 22/22, including "refuses a percent-encoded control character too" and "reads the settings at kernel:bootstrapped, never in init() or start()".

Local runs (under scripts/pm/os-verify-lock.sh): the rework round on 806c55d, and what ran again on head 664bd70
  • pnpm install --frozen-lockfile: exit 0. pnpm turbo run build --concurrency=2 --filter='./packages/**' --filter='./examples/**': exit 0, 85/85 tasks. gen:skill-refs then check:generated: exit 0, tree clean.
  • pnpm --filter @objectstack/knowledge-turso test: exit 0, 3 files, 155/155. typecheck: exit 0.
  • pnpm --filter @objectstack/core exec vitest run --maxWorkers=2 src/capability-composition.test.ts: exit 0, 21/21. pnpm --filter @objectstack/core typecheck: exit 0.
  • pnpm --filter @objectstack/verify exec vitest run --maxWorkers=2 src/harness.required-providers.test.ts: exit 0, 15/15 (19.0 s of tests locally; the header's budget is re-derived to 28). pnpm --filter @objectstack/verify typecheck: exit 0.
  • pnpm --filter @objectstack/cli exec vitest run --project unit --maxWorkers=2 src/utils/boot-preparation-parity.test.ts test/serve-capability-identity.test.ts src/commands/knowledge/knowledge.test.ts: exit 0, 3 files, 143/143. pnpm --filter @objectstack/cli typecheck: exit 0. The rest of the cli suite is left to CI.
  • pnpm --filter @objectstack/service-knowledge test: exit 0, 14 files, 452/452. pnpm --filter @objectstack/service-settings test: exit 0, 77 files, 1521/1521 (after fix(settings)!: retire @objectstack/knowledge-ragflow and the Knowledge page's RAGFlow adapter option #37477's edits to the same manifest and locales). scripts/platform-catalog.test.ts (spec): exit 0, 20/20.
  • The pgvector live cell, as CI's step runs it: OS_TEST_POSTGRES_URL=postgres://postgres:postgres@127.0.0.1:5432/postgres OS_EXPECT_LIVE_DIALECT_MATRIX=1 pnpm --filter @objectstack/knowledge-pgvector exec vitest run live-postgres: exit 0, 5 files, 65/65, none skipped (4 files, 59/59 before the merge of main brought feat(knowledge-pgvector): a changed fingerprint builds a new generation and switches to it #37492's file). Server: PostgreSQL 16.15 with the vector extension 0.6.0 (the distribution's postgresql-16-pgvector), not CI's pinned pgvector 0.8.7 image.
  • Ran again on this head (the token commit touches knowledge-turso, one comment in the settings manifest, the docs page and the changeset): pnpm --filter @objectstack/knowledge-turso test: exit 0, 3 files, 156/156 (plugin.test.ts 22/22); its typecheck: exit 0; turbo run build of @objectstack/knowledge-turso and @objectstack/service-settings: exit 0, 20/20 tasks. Everything above this line was run on 806c55d and not again.
Rework round: each new test turns red without its fix
  • M1. With the decoded read removed from carriesControlCharacter (the raw test alone, as on abf337b): plugin.test.ts 2 failed / 19 passed, "refuses a percent-encoded control character too" and "a saved URL with a NUL byte, or outside the data directory, never reaches the libSQL client". Restored (byte-identical to the committed file): 21/21.
  • S2, S3, S4. With stateDir and optional: true removed from core and core rebuilt: harness.required-providers.test.ts 3 failed / 12 passed. The file-database case answers { ok: false } (the saved file under OS_HOME is outside the app's data directory); the missing-store case throws the "could not load it" boot error; the dependency pin reports @objectstack/knowledge-turso as not a dependency. Restored and rebuilt: 15/15.
  • The auth token. With the acceptsAuthToken check removed from open(): plugin.test.ts 1 failed / 21 passed, "an auth token with a control character never reaches the libSQL client, saved or given; the reason never quotes it". Restored with git checkout (the committed file): 22/22.
Fix round: reverse verification of the settings read (one-off, no file kept)

A throwaway @objectstack/verify case booted a real kernel with KnowledgeServicePlugin, KnowledgeTursoPlugin({ urlFromSettings: true }) and a plugin that saves knowledge.turso_url from its kernel:ready handler (ordered after the settings bind).

  • This head: the read in start() answers source: 'default'; after the boot the store is healthy on the saved file and knowledge.db was never made. Probe 1/1 green.
  • plugin.ts restored to 969b372 (the pre-fix file), knowledge-turso rebuilt (dist marker absent): the probe is red, the saved file was never made and the default knowledge.db was opened; plugin.test.ts 3 failed / 16 passed (the two saved-URL cases and the new phase case).
  • Restored from HEAD (blob hash equal, git diff HEAD empty), rebuilt (dist marker present): probe green again.
The first build of #37099 on a real kernel, after the second merge (one-off, no file kept)

A throwaway @objectstack/verify case booted a real kernel with KnowledgeServicePlugin, KnowledgeTursoPlugin({ urlFromSettings: true }) and an app plugin that registers an embedder, a source on turso, a source naming the unmounted pgvector, and saves knowledge.turso_url from its kernel:ready handler. 1/1 green; readings after the boot:

  • the turso source: buildRecord is { trigger: 'boot', status: 'done', result: { ok: true, failed: 0 } }, then readIndexState answers current ("same fingerprint, same recipe hash"). The store is healthy on the saved file and the default knowledge.db was never made.
  • the pgvector source: no build record; readIndexState answers { state: 'unreadable', due: false } with the coded refusal's text ("adapter 'pgvector' is not mounted (mounted: turso)"). Boot log: one ERROR line from the reading of unmounted adapters, one WARN line "is not built at boot" from the build pass.
Derived gates (node scripts/pm/dispatch-gates.mjs --commands, 166 commands)

Remaining

🤖 Generated with Claude Code

…ector store

PostgreSQL gets pgvector on the same database; any other database gets
turso on .objectstack/data/knowledge.db. A store URL saved in settings is
held to the data directory and refused on a NUL byte before libSQL. A
source naming an unmounted adapter: boot ok, index/search answer 503.

Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JQwxbWZjh7mWMsJZHnGWwZ
@github-actions github-actions Bot added size/xl dependencies Pull requests that update a dependency file documentation Improvements or additions to documentation tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Nov 26, 2026
@github-actions

github-actions Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 7 package(s): @objectstack/cli, @objectstack/core, @objectstack/knowledge-turso, @objectstack/service-knowledge, @objectstack/service-settings, @objectstack/spec, @objectstack/verify, touching 49 documentable anchor(s). ⚠️ 3 changed file(s) yielded no anchor (packages/cli/package.json, packages/plugins/knowledge-turso/src/index.ts, packages/verify/package.json), so the pages documenting them are NOT COVERED by this run — this is not a clean bill of health for those files.

20 hand-written doc(s) name something this change touched — list omitted above 15 rows. Re-derive on the tree named below: node scripts/docs-audit/affected-docs.mjs --json 0f6a1e518f3c4639b03f86a8c07d9d08d91bddb6.

⛔ 7 release-owned page(s) also affected — read-only, see AGENTS.md Documentation Guardrails.

What this run could not see
  • 3 changed file(s) yielded no anchor (packages/cli/package.json, packages/plugins/knowledge-turso/src/index.ts, packages/verify/package.json) — pages documenting those are invisible to this run
  • 1 anchor(s) matched too much of the corpus to be a work list: os serve (command, 52 pages)
  • 16 name(s) were too generic to anchor anything (single lowercase words)
  • the SDK route bridge reached 69 of 252 client-bound route-ledger rows — the other 183 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 183: 0 are remediable by widening that discovery convention (an in-repo file declares the path; the convention did not scan it); 59 are structural — on a ledger where NOT ONE row is declared in-repo, so no discovery change reaches them at any price; 124 are undecided (no in-repo declaration, on a ledger that has other in-repo registrars — absence and an unreadable spelling are not distinguishable here). The rows themselves: node scripts/docs-audit/affected-docs.mjs --bridge-coverage
  • a page that states a rule by its inputs shares no identifier with the emitter that implements the rule, so an emitter-only diff cannot list it — not on this run and not on any run. Measured on fix(driver-sql): emit varchar(maxLength) for a text field a declared index keys on #11430: content/docs/protocol/objectql/types.mdx documents the text-family column mapping by the ObjectQL type names it maps FROM (text / textarea / html) while the diff changed createColumn; it went unlisted, and it was the page that diff falsified, in four places. No shared token exists to detect this on, so a rule your change carries has to be re-read by hand in the pages that restate it.
  • a key NAME is not a key, so the hand re-read the line above prescribes can land on the wrong schema. The same spelling is authorable on one governed type and a [REMOVED] tombstone on another for each of active, aria, joins, objects, template, tools and version (censused on [finding] tools is a key on BOTH AgentSchema (tombstoned, dead) and SkillSchema (live, cloud-attested), so a name-based search attributes skill examples to the agent key — it produced a false stop-the-line alarm on PR #19059 #19093 over the liveness ledger's governed types, top-level keys); nothing in a search result distinguishes the two, so a grep hit on a LIVE example reads as evidence about the DEAD key. Measured on fix(spec): the agent.tools liveness row says dead — it claimed live on a key the schema tombstoned #19059: content/docs/ai/agents.mdx was reported as contradicting the agent.tools tombstone over its tools: example at :161, which is inside the defineSkill({ block opened at :155 — the page was already correct. Settle ownership by PARSING the value against both schemas, never by the name: that literal PASSES SkillSchema, and as an AgentSchema it FAILS at tools with the tombstone prescription. ⛔ These names are not the whole class — a key retired through a .strict() guidance map leaves no tombstone in the walked shape and none of them here (tool.category, live as AIToolDefinition.category).

Coarse fallback — 195 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): node scripts/docs-audit/affected-docs.mjs --json 0f6a1e518f3c4639b03f86a8c07d9d08d91bddb6 → packageMentionDocs.

Which tree this was computed on

This run read content/docs from 278c7178c687ebd677c573823454e19e9507b2e4 — the merge of head 664bd7025c947534e22040d6caccb70646491868 into base 0f6a1e518f3c4639b03f86a8c07d9d08d91bddb6, which is what actions/checkout gives a pull_request run. Not the PR head.

A worktree cut from an older main holds a different content/docs, so re-deriving there can legitimately return a different list — that is a different tree, not a wrong row. To answer on the same tree:

# while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 278c7178c687ebd677c573823454e19e9507b2e4 && git checkout 278c7178c687ebd677c573823454e19e9507b2e4
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 0f6a1e518f3c4639b03f86a8c07d9d08d91bddb6 664bd7025c947534e22040d6caccb70646491868 && git checkout -B drift-repro 0f6a1e518f3c4639b03f86a8c07d9d08d91bddb6 && git merge --no-ff 664bd7025c947534e22040d6caccb70646491868

node scripts/docs-audit/affected-docs.mjs --json 0f6a1e518f3c4639b03f86a8c07d9d08d91bddb6

⚠️ That checkout carried uncommitted changes, so the commit above does not fully identify what was read.

Advisory only, and a precision-first one (#9192): a page is listed because it names a
symbol, wire route or SDK method this diff touched — not because it mentions a changed
package. Each row says which anchor put it there, so a wrong row is reportable rather than
merely annoying. To re-verify, run the docs-accuracy-audit workflow scoped to these files:
node scripts/docs-audit/affected-docs.mjs 0f6a1e518f3c4639b03f86a8c07d9d08d91bddb6 → pass the list as
args.docs, on the commit named under Which tree this was computed on.

…-pvvkab

The one conflict, the requires-table row of skills/objectstack-platform/SKILL.md:
main's provider cell kept whole, the bare knowledge token added after
record-context. Priced bytes 24593 on main, 24605 here.

Claude-Session: https://claude.ai/code/session_01Utp6CYE8s5v1UX96GEfkcR
Co-authored-by: Claude <noreply@anthropic.com>
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#5 · os-bill · session_01Utp6CYtTDvfPQDzMbZnN5X

Contract-review-claim: session_01Utp6CYtTDvfPQDzMbZnN5X · head abf337b · 2026-11-26T09:07Z

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#5 · os-bill · session_01Utp6CYtTDvfPQDzMbZnN5X

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: abf337bd0945ee41e4c96c511e496ea59092ee41
Local-runs: probe — one throwaway script in the scratch dir calling the installed @libsql/client 0.18.0 createClient on a file: URL with %00 in its path (plus the same script on a plain file as control). Nothing of the PR was built, run or re-run. The grade of M1 turned on whether the encoded NUL really ends the process, and no check-run answers that.
Scope: packages/spec/src/kernel/platform-capabilities.ts, skills/objectstack-platform/SKILL.md, skills/objectstack-project/references/platform-catalog.md + packages/core/src/capability-providers.ts, packages/core/src/capability-composition.ts, packages/cli/src/commands/serve.ts, packages/verify/src/required-providers.ts, packages/cli/package.json, packages/verify/package.json, packages/plugins/knowledge-turso/src/plugin.ts, packages/services/service-knowledge/src/knowledge-service.ts, packages/services/service-knowledge/src/knowledge-service-plugin.ts, packages/spec/scripts/lib/platform-catalog.ts, packages/spec/scripts/platform-catalog.test.ts, scripts/check-skills-token-ratchet.mjs
Security-touching: yes

Inputs read: card #37102 body and all 6 comments (claim 7182935868, hand-off 7183577702, take-over 7184318627, amend 7184431271, os-dev report 7187364220, triage 7143836781); the PR body and its 38-file net diff against main (merge-base cc38a91; main moved 3 commits since, none in this PR's files); the 75 check-runs on the head (64 success, 11 skipped, 0 failure); ruling records 6819475461 and 6840575378; carried note 7181713320. The remainder of the diff (tests, locales, docs page, lockfile) is the lane seat's ACCEPT.

① Derived judgments

  • knowledge joins PLATFORM_CAPABILITY_TOKENS: a widening, right. defineStack refused requires: ['knowledge'] as an unknown token before; it accepts it now. Nothing leaves the list and no always-on slate entry moves (PLATFORM_ALWAYS_ON_CAPABILITIES is untouched, so the token is requested-only, as its comment says).
  • Metadata-protocol: added: right. The one new authorable text is the token in requires. No key is removed or re-typed.
  • Where it is declared, enforced and mounted.
    • Declared: packages/spec/src/kernel/platform-capabilities.ts (token, and provider row @objectstack/service-knowledge, edition open).
    • Enforced: defineStack at authoring (existing code, read not reviewed); the spec/core/CLI drift tests are green in Test Core.
    • Mounted: CAPABILITY_PROVIDERS.knowledge in packages/core/src/capability-providers.ts (main provider KnowledgeServicePlugin), then resolveCapabilityExtras / resolveKnowledgeStore in capability-composition.ts (one store from KNOWLEDGE_STORE_PROVIDERS), read by the serve.ts resolver loop and by constructServedProviders in @objectstack/verify.
  • Core public surface: widened only. New exports resolveCapabilityExtras, resolveKnowledgeStore, KNOWLEDGE_STORE_PROVIDERS, CapabilityDatabase, CapabilityExtra, KnowledgeStoreSpec; CapabilityArgumentInput.database and constructServedProviders({ database }) are optional additions.
  • Host-mounted service: unchanged, right. Both loops continue on the main provider's identities before the extras are read, so a host that mounts KnowledgeServicePlugin gets neither a second service nor a store (card item 4).
  • service-knowledge: widened. getAdapter still throws for an unknown adapter, now with code: 'SERVICE_UNAVAILABLE', status: 503; a multi-source search lists the source in refused instead of dropping it with a warn. The message text changed; no caller in the diff matches on it.
  • The rulings say what the PR claims. Both quotations in the PR body match records 6819475461 (Adding a top-level key or a bound enum member reds two-way skill gates in both card orders under the skills split #32584, ruling A) and 6840575378 ([Decision] Under ruling A (#32584), may the PR that adds a key raise the token ceiling of the published skill file its enumeration row lands in? #32673, letter A) word for word. PLATFORM_CAPABILITY_TOKENS is a symbol bound to a registered exhaustive section (requires-capability-tokens in scripts/check-skill-identifier-liveness.mjs, intersected with CAPABILITY_PROVIDERS), so the bare token in skills/objectstack-platform/SKILL.md is the enumeration row ruling A orders. [Decision] Under ruling A (#32584), may the PR that adds a key raise the token ceiling of the published skill file its enumeration row lands in? #32673 speaks of "a metadata key" and "that skill file's token cap"; applying it to a capability token and to the catalog's hand-written ceiling follows feat(capabilities): requires record-context mounts the record-context service, so get_record_context is served over MCP #37303's precedent on the same two rows, and the lane text (lanes/skills.md lines 14-16) covers bound-symbol members.
  • One narrowing the PR does not declare: the install surface of @objectstack/cli and @objectstack/verify. See S3.

② Semver level

  • Clause-②: yes is right for the token, and the changeset carries the same three declaration lines as the PR body.
  • Levels match what is published: spec, core, cli, verify, service-knowledge, knowledge-turso minor (new token, new exports, new option, new behaviour); service-settings patch (one example string and a comment). knowledge-pgvector gains only a test file and needs none. Check Changeset is green.
  • The changeset sentence "the token adds only what is not already mounted" overstates one case: a host that mounts the service and no store gets no store from the runtime. The core comment and the docs page say it correctly. Changeset prose is outside ④; named for the seat.

③ Boundary flags

Dev flags and reviewer notes

Security

  • The token is a deployment mount switch, not an access gate. It restricts nobody: it decides whether the knowledge service, its settings page and its tools exist. Who may search or index is the service's own admission code, which this diff does not touch (read, not reviewed). The settings namespace it brings is manage_platform_settings for read and write.
  • The PR does add security behaviour: a settings-supplied store URL and auth token now reach a native client, behind a path confinement and a control-character refusal. That refusal has a hole (M1).
  • A coded refusal now tells any admitted search caller which adapters are mounted ("mounted: turso"). Low; noted.
  • A settings writer can point the store at any libsql://, http(s):// or ws(s):// host, and the indexed passages go there. That is the operator's power by design; noted, not graded.

SQL push-down

  • No finding. The new reads are two keyed settings.get('knowledge', key) calls at boot and an in-memory filter over registered sources. No id materialisation, no in-app join.

Escalation for the seat (not graded, outside the inputs)

  • The catalog row teaches every author, hosted ones included, that knowledge mounts knowledge search. Hosted registration is the card's out-of-scope row 14. Whether cloud's loader warns or stays silent on the token today could not be read from here.
  • On a multi-replica deployment over MySQL, MongoDB or remote libSQL, each replica gets its own local knowledge.db. The card chose "any other database"; the docs page does not say what that means with more than one replica.

④ Design judgment

packages/spec/src/kernel/platform-capabilities.ts — holds against its first consumers. The comment's three sentences (one store chosen by the database; requested, never always-on; without the token no service, store or settings page) agree with core, with serve.ts and with the verify control case. Provider row and core row name the same package.

skills/objectstack-platform/SKILL.md — the one added token, read against the section's sentences:

  • "@objectstack/service- + the token" gives @objectstack/service-knowledge: matches CAPABILITY_PROVIDERS.knowledge.pkg.
  • No ° mark: right, the token is not on the always-on slate.
  • "The CLI expands each token through the CAPABILITY_PROVIDERS registry": true for the main provider. The store comes from a second table; the row does not say so, which the enumeration-row rule permits (teaching rides skills/objectstack-ai and the MCP authoring contract teach knowledge_source as metadata: name, an explicit content list, no wildcard, the retired keys, and a create seed #37310).
  • "Declaring is a demand … provider package is absent is a hard boot error": true for the service; an unloadable store warns and the boot goes on, which the sentence does not contradict.
  • Ratchet: wc -c gives 24613 bytes on main and 24625 on the head; the stamp line is 20 bytes on both. Priced 24593 to 24605 (+12, the bytes of one space and the backticked token). ceil(24593 / 4) = 6149, ceil(24605 / 4) = 6152. The row reads 6152: pinned at the measurement, nothing else cut.

skills/objectstack-project/references/platform-catalog.md — generated; the row is knowledge | knowledge search and its vector store | open | on requires. Edition and boot cell derive from the spec rows and are right. The description is 37 bytes; the module's hand-written text was last pinned at 6902 by #37303 and nothing else in it changed since, so 6902 + 37 = 6939 and ceil(6939 / 4) = 1735, the new ceiling. scripts/platform-catalog.test.ts is green in Test Core.

Findings

M1 (must-fix) — A saved knowledge.turso_url with a percent-encoded NUL passes both guards and ends the server process at every boot.

  • Contract: capability-composition.ts says the store "refuses when it carries a NUL byte, before it reaches the libSQL client"; the settings manifest, the changeset and the docs page say the same, and it is the requirement carried from knowledge-turso moves into objectstack: Apache-2.0, the platform embedder and splitter, listing, generations, the contract suite #37107 (7181713320).
  • Code: resolveSettingsStoreUrl and resolveStoreUrl in packages/plugins/knowledge-turso/src/plugin.ts test CONTROL_CHARACTER against the raw URL only. file:DATA_DIR/k%00.db has no raw control character. fileOf decodes it (its own comment: "libSQL percent-decodes the path it opens"), the confinement check passes because the file sits inside the data directory, every realpathSync on the NUL path throws into a bare catch, and the raw URL goes to createClient.
  • libSQL: parseUri in @libsql/core 0.18.0 runs percentDecode on the path and hands it to the native Database.
  • Probe: createClient({ url: 'file:…/k%00x.db' }) panics in libsql-0.9.30/src/local/connection.rs:57 with NulError and the process aborts, exit 134. The control on a plain file opens.
  • Effect: anyone holding manage_platform_settings can save a value that aborts the process inside the kernel:bootstrapped handler on every later boot. No JavaScript catch sees it; the server stays down until the row is changed from outside.
  • Before this PR nothing read that setting, so the PR opens the path. The tests cover the raw byte only (plugin.test.ts lines 200-209 and 345-352).
  • Fix shape: refuse a control character in the decoded path as well (in resolveStoreUrl, so both doors hold), and add %00 and %0a cases to both tests.

S1 (should-fix) — The PostgreSQL acceptance row has not executed on any commit of this PR, and the PR body says it has.

  • Evidence is under reviewer note (2) in ③.
  • The PR body's Tests section says the cell "Runs in CI's existing live-postgres step" and Remaining says it "has only run in CI's live-postgres step". Neither is true on a PR head.
  • Run the cell once against the pgvector image on the fixed head and correct both sentences, or state plainly that the merge queue is its first run.

S2 (should-fix) — The arm os dev and os serve actually mount on SQLite has no test on a real kernel.

  • resolveKnowledgeStore answers { projectRoot, urlFromSettings: true } for a file database. @objectstack/verify boots { driver: 'sqlite-wasm', url: ':memory:' } by default, which takes the in-memory arm; the serve.ts loop is exercised by no test; the pgvector arm is S1.
  • So the card's row "turso mounted on the local file, a record write is indexed and found" is met by an in-memory store, and the saved-URL ordering rests on a double that asserts the kernel's hook order and the settings bind by construction. The double already missed this defect once (the fix round), and M1 sits on the same path.
  • The dev wrote the real-kernel case twice as a one-off and discarded it. Keep one: constructServedProviders with a file database in a temporary root, a saved turso_url, and the store open on the saved file.

S3 (should-fix) — @objectstack/cli and @objectstack/verify now hard-depend on libsql, which narrows where they install.

  • packages/cli/package.json and packages/verify/package.json add @objectstack/knowledge-turso under dependencies; it depends on @libsql/client, which depends on libsql 0.5.29, whose manifest carries os: darwin, linux, win32 and cpu: x64, arm64, wasm32, arm.
  • On main libsql is never a hard dependency of the CLI or the runtime: @objectstack/driver-turso is an optional peer on purpose (the turso 迁回本仓后,CLI 的 URL→driver 解析仍对 libsql:// 抛 UnsupportedDriverError —— runtime 的 provisioning 却把 turso 排在偏好第一位,两处口径相反 #5602 comment in serve.ts), and better-sqlite3 is an optional dependency.
  • npm refuses a non-optional dependency outside its os/cpu list (EBADPLATFORM), so a CLI install on such a platform would fail whether or not the app asks for knowledge. That is a narrowing the Clause-②: yes line and the changeset do not declare. Not measured here; read from the manifests.
  • The PR's own acceptance note offers the remedy: make the store an optional dependency. serve.ts already warns when an extra cannot be imported; verify's "broken install" sentence would need the matching case. Otherwise a maintainer ruling accepts it and the changeset says so.

S4 (should-fix) — "beside the dev database" is false under OS_HOME or os start --home, and Settings cannot repair it.

  • resolveKnowledgeStore hands the store projectRoot: packageRoot (the config's directory), so the file is CONFIG_DIR/.objectstack/data/knowledge.db.
  • The platform database follows resolveDatabaseStateDir: homeDir, then OS_HOME, then the project root. With OS_HOME on a volume the database is at OS_HOME/data/objectstack.db and the knowledge file stays in the app directory.
  • resolveSettingsStoreUrl holds a saved file: URL to that same app directory, so an operator cannot move the file onto the volume from Settings.
  • Effect on the self-hosted container shape the card names: the index is lost at each redeploy and re-embedded at boot by service-knowledge: a source that was never built gets built, and an operator can start a rebuild #37099's first build, or the store is unavailable on a read-only app directory.
  • Fix shape: derive the store's data directory from the directory the boot resolved for the platform database, or say so in the jsdoc and docs and file the card.

N1 (nit) — resolveKnowledgeStore reads only the bare :memory: as in-memory. file::memory: and an empty wasm-sqlite: URL are in-memory databases too (sqliteFilenameFromUrl) and get the file arm. The driver === 'memory' arm cannot be reached from serve: that engine is retired and refused upstream.

N2 (nit) — With the fix for S4 aside, the settings example file:./.objectstack/data/knowledge.db resolves from the working directory while the confinement is measured from the config's directory; os serve path/to/app/objectstack.config.ts from another directory refuses its own example. It fails closed, with a message naming the right directory.

N3 (nit) — The step comment in ci.yml says the substring "selects the three *.live-postgres.test.ts files"; this PR adds a fourth. Not in the diff; for the carrier of S1.

Not broken, tried: path escape through .., a symlink, a file://HOST/ authority, a fragment (#/../.., which libSQL refuses and openClient turns into a 503 reason), the platform database's own file, a second service or a second store under a host-mounted one, and the store choice when the boot resolved no database (environment variables decide, as documented).

Implemented-by: claude/project-thread-pvvkab
Reviewed-by: session_01Utp6CYtTDvfPQDzMbZnN5X

VERDICT: FAIL

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#5 · os-bill · session_01Utp6CYtTDvfPQDzMbZnN5X

席位核对

Head-sha: abf337bd0945ee41e4c96c511e496ea59092ee41
REWORK: L1, seat repo:objectstack#5. Contract record 7187791236 (CONTRACT_REVIEW_TIER, verified on the transcript) reads FAIL on M1. The token, the rulings it cites, the two ceilings and the host-mounted case all hold.

  1. Shape: open draft against main, 38 files, Fixes #37102, Clause-②: yes, Metadata-protocol: added. Tier H (skills/**), Security-touching: yes. 64 success, 11 expected skips, 0 failed.
  2. Premise: requires: ['knowledge'] mounts the service plus one store chosen by the database. A deployment without the token is unchanged.
  3. Owed before ACCEPT:
    • M1. A saved knowledge.turso_url with a percent-encoded NUL (file:…/k%00.db) passes both guards in knowledge-turso/src/plugin.ts, because they test only the raw URL. libSQL percent-decodes the path and the native client panics: the process aborts (exit 134, probed) on every boot until the row is changed from outside. Anyone with manage_platform_settings can save it, and this PR opens the path. Refuse control characters in the decoded path too, inside resolveStoreUrl so both doors hold, and add %00 and %0a cases to both tests.
    • S1. The pgvector live cell has never run on this PR. temporal-conformance skips on pull_request (check-run 139784795215), and Test Core collected the file with both cases skipped. Correct the two sentences in the PR body that say it ran, or run it once against the pgvector image. Its first real run will be the merge queue.
    • S2. Keep one real-kernel case for the file + settings arm that os dev / os serve mount on SQLite: constructServedProviders with a file database in a temp root, a saved turso_url, and the store open on the saved file. You wrote it twice as a one-off; keep it. The double has already missed one defect on this path.
    • S3. @objectstack/cli and @objectstack/verify now hard-depend on libsql, whose manifest restricts os/cpu. That narrows where the CLI installs, and neither Clause-② nor the changeset declares it. Take your own acceptance note's remedy: make @objectstack/knowledge-turso an optional dependency. serve.ts already warns when an extra cannot be imported; add the matching verify case.
    • S4. Under OS_HOME / os start --home the store file stays in the config directory while the platform database moves, and the settings confinement stops the operator from moving it. Either derive the store's directory from the one the boot resolved for the platform database, or say so in the jsdoc and docs and file a card under 专题:知识检索平台化(应用写一份知识源配置就有可用的检索:开源、托管、企业版都能用) #37000.
    • service-knowledge: a knowledge source that names an unregistered adapter fails silently (boot clean, search answers [], index throws a bare Error) #37479 must be re-scoped before this lands (this PR delivers most of its "Done when"). The residue is one boot line instead of two, plus the publish-time refusal. The os-dev report should name it as the carrier.
    • The same reviewer reads the delta.
  4. Accepted deviations (nits, record only): N1 (file::memory: takes the file arm), N2 (the settings example resolves from cwd; it fails closed), N3 (the ci.yml comment says three live-postgres files; ride S1's fix).
  5. Out of scope and where it went:
  6. Landing terms: Tier H. Owed: M1 and S1 to S3 closed, S4 closed or carried, a same-head delta PASS, then the seat's ACCEPT and the hand-off to os-zhuang and hotlong with the security label.

…sed; the store follows OS_HOME; the libSQL store is an optional dependency

Rework after the contract review of abf337b (record 7187791236).

- M1: resolveStoreUrl and resolveSettingsStoreUrl refuse a control character
  behind a percent escape too. libSQL decodes the path it opens, so a saved
  file:.../k%00.db reached the native client as a NUL byte and ended the
  process at every boot.
- S2: one real-kernel case for the file-database arm: the store opens the
  file the operator saved and a record write is found by search.
- S3: @objectstack/knowledge-turso is an optional dependency of the CLI and
  of @objectstack/verify. The store's row and extra carry optional: true;
  verify warns and goes on where it cannot be imported, as serve does.
- S4: the store's data directory follows OS_HOME (os start --home), the
  directory the default platform database is kept in. New option stateDir.
- Docs: where the file is, more than one replica, an install without the
  libSQL client.

Claude-Session: https://claude.ai/code/session_01Utp6CYE8s5v1UX96GEfkcR
Co-authored-by: Claude <noreply@anthropic.com>
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#5 · os-bill · session_01Utp6CYtTDvfPQDzMbZnN5X

Contract-review-claim: session_01Utp6CYtTDvfPQDzMbZnN5X · head 806c55d · 2026-11-26T13:39Z

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#5 · os-bill · session_01Utp6CYtTDvfPQDzMbZnN5X

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: 806c55d289e4cab05369e0dc31e75741ee4867bf
Local-runs: none
Scope: packages/spec/src/kernel/platform-capabilities.ts, skills/objectstack-platform/SKILL.md, skills/objectstack-project/references/platform-catalog.md + packages/core/src/capability-providers.ts, packages/core/src/capability-composition.ts, packages/cli/src/commands/serve.ts, packages/verify/src/required-providers.ts, packages/cli/package.json, packages/verify/package.json, packages/plugins/knowledge-turso/src/plugin.ts, packages/services/service-knowledge/src/knowledge-service.ts, packages/services/service-knowledge/src/knowledge-service-plugin.ts, packages/spec/scripts/lib/platform-catalog.ts, packages/spec/scripts/platform-catalog.test.ts, scripts/check-skills-token-ratchet.mjs
Security-touching: yes

Delta round on record 7187791236 (FAIL at abf337b) and the seat's REWORK 7187907110. Read: the delta abf337b..215cebf (12 files), the merge 806c55d (parents 215cebf and main at 5dbcc02), the net diff against main, os-dev report 7193648552, the PR body on this head, and the check-runs on this head. The installed @libsql/core and libsql JavaScript was read to judge M1; nothing was run.

① Derived judgments

  • Unchanged from round one and still right: the knowledge token is a widening, Metadata-protocol: added holds, and the spec and skills hunks are byte-identical to the ones reviewed at abf337b.
  • New public surface in the delta, all additive:
    • KnowledgeTursoPluginOptions.stateDir, and a second optional parameter on defaultStoreUrl and dataDirectoryOf.
    • KnowledgeStoreSpec.optional and CapabilityExtra.optional.
  • The undeclared narrowing of round one is gone. @objectstack/knowledge-turso moved from dependencies to optionalDependencies in both packages/cli/package.json and packages/verify/package.json, and the lockfile agrees. No source file in cli, verify or core imports the package statically.
  • The merge is clean. git merge-tree of the two parents gives tree c91897ef, the tree of 806c55d: no hand edit rode the merge. Against main at 5dbcc02 the PR is the same 38 files as before. Fourteen files changed on both sides (the docs page, the settings manifest, eleven locales, the lockfile); the manifest and locale hunks land as the one-line example change beside fix(settings)!: retire @objectstack/knowledge-ragflow and the Knowledge page's RAGFlow adapter option #37477's retirement of the RAGFlow option. main has moved nine commits since; none touches this PR's files.
  • Ratchet rows, re-measured on this head: wc -c gives 24613 bytes on main and 24625 on the head, stamp line 20 on both; priced 24593 to 24605, ceil(24605 / 4) = 6152, the row's value. The catalog module is untouched by the merge: 6902 + 37 = 6939, ceil(6939 / 4) = 1735, the test's value.

② Semver level

  • Clause-②: yes stands. Levels are unchanged and still match: stateDir and the optional fields are minor on packages already at minor.
  • The changeset now states the optional dependency and its reason, and the host-mounted sentence round one called overstated is corrected. Check Changeset is green.

③ Boundary flags

Check-runs on this head: 79 runs, 66 success, 13 skipped, 0 failure. The area's count of 75 (64 and 11) was read before the last PR-body edit restarted the PR-body workflows; the difference is those reruns. Test Core, Lint & Repo Gates, Validate Package Dependencies and the Governed Surface Queue Guard are green.

Report flags, answered

Security

  • The token is still a mount switch, not an access gate; nothing in the delta changes who may reach knowledge features.
  • The delta changes security behaviour in two places: the control-character refusal (M1) and the directory a settings URL is confined to, which now follows OS_HOME. The confinement is measured from the same directory the default file is made in, on both arms.

Escalated, not measured: the auth token. turso_auth_token is a second settings value that reaches the client unchecked. For a file: URL the JavaScript wrapper passes it into the native open call (databaseOpen(path, authToken, …) in libsql/index.js). Whether the native library does anything with it on a local file, and so whether a NUL in it can abort the process as the path did, cannot be read from the installed package and was not probed this round. For a remote URL it travels in a request header, where a bad value is a catchable JavaScript error. One probe settles it; refusing a control character in the token costs one line. Not graded: no defect is shown.

SQL push-down: no new read in the delta beyond the two keyed settings reads of round one. No finding.

④ Design judgment

No must-fix, no should-fix.

M1: closed

  • carriesControlCharacter tests the URL as written and again with every %XX escape read as its byte, and both resolveStoreUrl and resolveSettingsStoreUrl call it before anything else. Read against libSQL's parser (percentDecode is one decodeURIComponent over the path, the authority and each query pair):
    • %00, %0a, %0A, %0d, %09, %7f, %7F: refused. The escape pattern is case-insensitive and the range is U+0000 to U+001F plus U+007F.
    • In the host (libsql://db%00.turso.io), the path, the query (?authToken=a%00b) and a fragment: refused, because the test runs over the whole URL.
    • Double encoding (%2500): passes, correctly. libSQL decodes once, to the three characters %00, which is a file name. fileOf decodes once too, so the confinement judges the same name libSQL opens.
    • %%300: passes the test in one pass and is not a hole: decodeURIComponent throws on it, libSQL answers URL_INVALID, and openClient turns that into a 503 reason.
    • Overlong or %u spellings of NUL (%C0%80, %u0000): decodeURIComponent rejects both, same catchable path. A control character is one UTF-8 byte, so a single %XX is its only spelling the decoder accepts; the byte-wise read covers a superset.
  • Tests: the two resolvers over six refused URLs and two controls, and the plugin never reaching a mocked createClient with %00 or %0a. The report's ablation (the decoded read removed, 2 failed) is consistent with the code.

S1: closed

  • The PR body's Tests and Remaining sections now say the cell has not run in CI on any commit of this PR and cannot on a PR head. See ③ for what the local run does and does not show.

S2: closed

  • harness.required-providers.test.ts keeps one real-kernel case: constructServedProviders on a file: database takes the file arm, the two providers boot under bootStack with the real settings service, a plugin saves turso_url from its kernel:ready handler, and the case asserts the store healthy on the saved file, neither default file made, and a record write found by search. That is the kernel's own order under test, not a double's.

S3: closed

  • See ①. KNOWLEDGE_STORE_PROVIDERS.turso carries optional: true; resolveCapabilityExtras passes it through; constructServedProviders imports an optional extra first and, where that fails, warns once and continues, which is what serve.ts does on the same install. The pin test now requires the package under optionalDependencies and forbids it under dependencies. pg is pure JavaScript, so knowledge-pgvector staying a hard dependency narrows nothing.

S4: closed

  • resolveKnowledgeStore hands the file arm stateDir from OS_HOME; dataDirectoryOf answers STATE_DIR/data, with the same ~ rule as resolveDatabaseStateDir. os start always exports OS_HOME as its resolved home and makes HOME/data (start.ts lines 195-200 and 514), so on that command the store file is beside the default database in every case. The settings confinement uses the same function, so a saved file on the volume is accepted and one under the app directory is refused (pinned in plugin.test.ts). The multi-replica paragraph is in the docs page.

Nits, carried or new. None moves the verdict.

N1 (nit) — unchanged, accepted by the seat: only the bare :memory: is read as in-memory.

N2 (nit) — unchanged, and wider with S4 as the report says: the settings example file:./.objectstack/data/knowledge.db is outside the data directory under OS_HOME. It is refused with a message naming the right directory.

N3 (nit) — unchanged: the ci.yml step comment counts three live-postgres files; there are five on this head. Outside the card's surface.

N4 (nit) — the jsdoc of knowledge.manifest.ts still says a saved file is held to "the project's .objectstack/data/ directory" and names only "a NUL byte". Both are now narrower than the code (the state directory, the percent-encoded spelling). A comment, not behaviour.

N5 (nit) — without OS_HOME, serve.ts resolves the default database from config.standalone.projectRoot when the config sets it, while the store is handed the config file's directory. An app that sets that key gets the two files in different directories. Same class as the documented URL case; a line in the jsdoc or the follow-up card covers it.

Implemented-by: claude/project-thread-pvvkab
Reviewed-by: session_01Utp6CYtTDvfPQDzMbZnN5X

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#5 · os-bill · session_01Utp6CYtTDvfPQDzMbZnN5X

席位核对

Head-sha: 806c55d289e4cab05369e0dc31e75741ee4867bf
REWORK — L1, seat repo:objectstack#5, delta round 1

  1. Shape: draft against main, Tier H (skills catalog row). Security-touching. The head is rework commit 215cebf plus one main merge at 5dbcc02; the reviewer reproduced the merge tree exactly, and the PR is still the same 38 files.
  2. Premise: M1 and S1–S4 are closed. The store URL refuses percent-encoded control characters anywhere in the URL, re-broken against double encoding, %0d, %09, mixed case, host, path, query and fragment. The live cell has not run in CI; the merge queue is its first run on pgvector 0.8.7.
  3. Gates: delta record 7193770862 (same reviewer, CONTRACT_REVIEW_TIER, verified on the transcript) reads PASS. CI on this head is green.
  4. Owed before the hand-off (one small security hardening):
    • The record escalates turso_auth_token: it is a second settings value that reaches the libSQL client unchecked, and for a file: URL the wrapper passes it into the native open. Whether a control character in it can abort the process the way the path did is unmeasured. The seat does not hand a security-touching PR to the maintainer with that open. Refuse control characters in the token, the same rule as M1, with a pin and its ablation. It is the same class as M1 and inside the same surface.
    • N4: the knowledge.manifest.ts jsdoc ("the project's .objectstack/data/", "a NUL byte") is narrower than the code. Fix it in the same push.
    • N5 (without OS_HOME, the store and the default database can resolve to different directories) is accepted; os start always exports OS_HOME. N1–N3 are carried as before.
  5. Out of scope and where it went: service-knowledge: a knowledge source that names an unregistered adapter fails silently (boot clean, search answers [], index throws a bare Error) #37479 (re-scoped by the area to carry the residue). feat(spec)!: form is a metadata type of its own, and the form doors read a form over both types #37422 pins the combined ratchet row if it lands second.
  6. Next: push, then knock. The same reviewer reads the token check alone. Then the seat ACCEPTs with the maintainer brief, adds security, and hands off to os-zhuang and hotlong.

…token

The auth token is the second settings value handed to the libSQL client.
One with a NUL byte, a line break or another control character is now
refused in the plugin's open path, for the saved setting and the plugin
option alike, before the client is created; the reason never quotes the
token. It is read as written: the client percent-decodes a URL, never
this option.

Also corrects the knowledge settings manifest jsdoc (the data directory
follows the state directory; the percent-encoded spelling is refused).

Claude-Session: https://claude.ai/code/session_01Utp6CYE8s5v1UX96GEfkcR
Co-authored-by: Claude <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file documentation Improvements or additions to documentation size/xl tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Open runtime: requires: ['knowledge'] mounts the knowledge service, and pgvector on PostgreSQL

3 participants